#include<bits/stdc++.h>
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
//#pragma GCC optimize(2)
//#pragma GCC optimize(3)
//#pragma GCC optimize("Ofast,unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4.1,sse4.2,avx,avx2,popcnt,tune=native")
//#include <immintrin.h>
//#include <emmintrin.h>
#define int long long
#define ls(x) ((x)*2)
#define rs(x) ((x)*2+1)
#define pii pair<int,int>
#define fi first
#define se second
#define Debug(...) fprintf(stderr, __VA_ARGS__)
#define For(i,a,b) for(int i=a,i##end=b;i<=i##end;i++)
#define Rof(i,a,b) for(int i=a,i##end=b;i>=i##end;i--)
#define rep(i,  b) for(int i=1,i##end=b;i<=i##end;i++)
using namespace std;
const int N=1e6+5,base=999983,Mod=1e9+7;
//char buf[(1<<21)+5],*p1,*p2;
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
inline void chmx(int &x,int y){(x<y)&&(x=y);}
inline void chmn(int &x,int y){(x>y)&&(x=y);}
int _base=1;
inline int mol(const int x){return x-Mod*((__int128)_base*x>>64);}
inline void Add(int &x,const int y){x=mol(x+y);}
inline int read(){
	int f=0,x=0;
	char ch=getchar();
	while(!isdigit(ch)){f|=(ch=='-');ch=getchar();}
	while(isdigit(ch)){x=(x<<3)+(x<<1)+(ch^48);ch=getchar();}
	return f?-x:x;
}
void print(int n){
    if(n<0){
        putchar('-');
        n*=-1;
    }
    if(n>9) print(n/10);
    putchar(n%10+'0');
}
int n,fa[N];
vector<int>q[N],d[N];
int dep[N],siz[N];
int mxdep[N],son[N]; 
void dfs(int x){
	dep[x]=dep[fa[x]]+1;
	siz[x]=1;//d[dep[x]].push_back(x);
	mxdep[x]=dep[x];
	for(auto y:q[x]){
		dfs(y);
		siz[x]+=siz[y];
		mxdep[x]=max(mxdep[x],mxdep[y]);
		if(mxdep[y]==mxdep[x]) son[x]=y;
	}
}
//int f[N][2];
int mi[N],Dep;
inline int ksm(int a,int b){
	int res=1;if(a>=Mod) a-=Mod;
	while(b){
		if(b&1) res=res*a%Mod;
		a=a*a%Mod;
		b>>=1;
	}return res;
}vector<int>dp[N],Big[N];
//void dfs2(int x){
//	if(dep[x]==Dep) return;
//	int res=1;
//	int p=1;
//	for(auto y:q[x]){
//		dfs2(y);
//		p=p*(f[y][0]+f[y][1])%Mod;
//		res*=f[y][0];res%=Mod;
//	}
//	for(auto y:q[x]){
//		(f[x][1]+=res*ksm(f[y][0],Mod-2)%Mod*f[y][1])%=Mod;
//	}f[x][0]=(Mod+p-f[x][1])%Mod;
//}
int res[N];
#define L(x) (mxdep[x]-dep[x]) 
void DP(int x){
	if(son[x])DP(son[x]),dp[x].swap(dp[son[x]]),Big[x].swap(Big[son[x]]);
	dp[x].push_back(1);Big[x].push_back(1);
	if(!son[x])return;int mxd=0;
	for(auto y:q[x]){
		if(y==son[x]) continue;
		DP(y);mxd=max(mxd,L(y)+1);
	}
	For(j,0,mxd)res[j+1]=0;
	For(j,0,mxd)res[j]=(mi[Big[x][L(x)-j]]-dp[x][L(x)-j]+Mod)%Mod;
	for(auto y:q[x]){
		if(y==son[x])continue;
		For(j,0,L(y)) res[j+1]=res[j+1]*(mi[Big[y][L(y)-j]]-dp[y][L(y)-j]+Mod)%Mod;
	}
	For(j,0,mxd)dp[x][L(x)-j]=res[j]%Mod*ksm(mi[Big[x][L(x)-j]]-dp[x][L(x)-j]+Mod,Mod-2)%Mod*dp[x][L(x)-j]%Mod;
	for(auto y:q[x]){
		if(y==son[x]) continue;
		For(j,0,L(y))
		(dp[x][L(x)-1-j]+=res[j+1]*ksm(mi[Big[y][L(y)-j]]-dp[y][L(y)-j]+Mod,Mod-2)%Mod*dp[y][L(y)-j]%Mod)%=Mod;
	}
	for(auto y:q[x]){
		if(y==son[x])continue;
		For(j,0,L(y)) Big[x][L(x)-1-j]+=Big[y][L(y)-j];
	}
}
signed main(){
	_base=((__int128)_base<<64)/Mod;
	freopen("a.in","r",stdin);
	freopen("a.out","w",stdout);
	// ios::sync_with_stdio(false);
	// cin.tie(0); cout.tie(0);
	mi[0]=1;
	For(i,1,N-5) mi[i]=mi[i-1]*2%Mod;
	n=read()+1;
	For(i,2,n)fa[i]=read()+1,q[fa[i]].push_back(i);
	dfs(1);int ans=0;DP(1);
	For(i,0,dp[1].size()-1) ans+=dp[1][i]%Mod*mi[n-Big[1][i]]%Mod;
//	for(auto v:dp[1]) cout<<v<<" "; puts("");
//	for(auto v:Big[1]) cout<<v<<" "; puts("");
//	For(i,1,n){
//		if(d[i].size()){
//			Dep=i;
//			For(j,0,n) f[j][0]=f[j][1]=0;
//			for(auto v:d[i]) f[v][0]=f[v][1]=1;
//			dfs2(1);
//			ans+=mi[n-d[i].size()]*f[1][1];ans%=Mod;
//		}
//	}
	print(ans%Mod);
#ifdef LOCAL
    Debug("\nMy Time: %.3lfms\n", (double)clock() / CLOCKS_PER_SEC);
#endif
	return 0;
}



